/* Model generation and testing for appendix*/
clear


cd "D:\Dropbox\Research Papers\Military Deployments and Coups\Data" 

use primary_coup_replication.dta

		
/*models that control for coup proofing */
set more off
eststo clear
eststo: logit coup l.lntroops100 l.counterbal i.regime_case_fe , robust
eststo: logit coup l.lntroops100 l.pararatio i.regime_case_fe, robust
eststo: logit coup l.lntroops100 l.pararatio l.counterbal  i.regime_case_fe, robust
eststo: logit coup l.lntroops100 l.pararatio l.dependence l.kappavv  l.threat_env l.excluded l.ln_terrorist_attack l.civil_war  l.lnmilex l.lnmilper l.lnrussian_troops l.marxist l.time l.time2 l.time3 i.regime_case_fe , robust

esttab _all using ..\Tables\Basic_Results_RR_Coup_Proofing.tex, replace ///
	mtitles("Naive" "Naive" "Naive" "Full Controls" "Temporal Controls")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.regime_case_fe)  ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"$*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")



/*base models */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.lntroops100, robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.domestic4 l.excluded i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.domestic4 l.excluded l.threat_env i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded l.time l.time2 l.time3 i.ccode1,  robust


esttab _all using ..\Tables\Basic_Results_Predictive.tex, replace ///
	mtitles("Naive" "Controls" "Past Coups" "Excluded" "Threat" "Cubic Polynomial")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.ccode1) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")


/* Spatial controls */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_coup i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_demo i.ccode1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_lntroops100 i.ccode1,  robust



esttab _all using ..\Tables\Spatial_Results_Predictive.tex, replace ///
	mtitles("Spatial Coups" "Spatial Democracies"  "Spatial Troops")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.ccode1) ///
	compress nonotes eqlabels(none)  ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses. " ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")

/* Coup types */
set more off
eststo clear
tsset ccode1 year
eststo: logit attempt l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded i.ccode1,  robust
eststo: logit military l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded i.ccode1,  robust
eststo: logit coup l.lntroops100 l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded i.ccode1 if l.demo_dummy == 1,  robust
eststo: logit coup l.lntroops100 l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded i.ccode1 if  l.demo_dummy == 0,  robust
eststo: logit coup l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.marxist l.past_coup l.excluded i.ccode1 if  coldwar == 1,  robust
eststo: logit coup l.lntroops100 l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded i.ccode1 if marxist == 0 ,  robust
 

esttab _all using ..\Tables\Sub_Samples_Results_Predictive.tex, replace ///
	mtitles("Attempts" "Military" "Democracies" "Non-Democracies" "Cold War" "Non-Marxist")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S)  drop(*.ccode1)  ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")
		

/* change in troops models */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.troop_change, robust
eststo: logit coup l.troop_change l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist i.ccode1,  robust
eststo: logit coup l.troop_change l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup i.ccode1,  robust
eststo: logit coup l.troop_change l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.domestic4 l.excluded i.ccode1,  robust
eststo: logit coup l.troop_change l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded l.time l.time2 l.time3 i.ccode1,  robust
esttab _all using ..\Tables\Basic_Results_delta_Predictive.tex, replace /// 
	mtitles("Naive" "Controls" "Past Coups" "Excluded" "Cubic Polynomial")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.ccode1) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")
		
		
		
/* Spatial controls */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_coup i.ccode1,  robust
eststo: logit coup l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_demo i.ccode1,  robust
eststo: logit coup l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_lntroops100 i.ccode1,  robust



esttab _all using ..\Tables\Spatial_Results_delta_Predictive.tex, replace ///
	mtitles("Spatial Coups" "Spatial Democracies"  "Spatial Troops")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.ccode1) ///
	compress nonotes eqlabels(none)  ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")

/* Coup types */
set more off
eststo clear
tsset ccode1 year
eststo: logit attempt l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded i.ccode1,  robust
eststo: logit military l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded i.ccode1,  robust
eststo: logit coup l.troop_change l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded i.ccode1 if l.demo_dummy == 1,  robust
eststo: logit coup l.troop_change l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded i.ccode1 if  l.demo_dummy == 0,  robust
eststo: logit coup l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.marxist l.past_coup l.excluded i.ccode1 if  coldwar == 1,  robust
eststo: logit coup l.troop_change l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded i.ccode1 if marxist == 0 ,  robust
 

esttab _all using ..\Tables\Sub_Samples_Results_delta_Predictive.tex, replace ///
	mtitles("Attempts" "Military" "Democracies" "Non-Democracies" "Cold War" "Non-Marxist")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S)  drop(*.ccode1) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")
		
		
/*temporal fixed effects */

/*base models */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.lntroops100 i.ccode1 i.year, robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist i.ccode1 i.year,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup i.ccode1 i.year,  robust
eststo: logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded i.ccode1 i.year,  robust


esttab _all using ..\Tables\Basic_Results_year_fe_Predictive.tex, replace ///
	mtitles("Naive" "Controls" "Past Coups" "Excluded")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) drop(*.ccode1 *.year) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; robust standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")

/*Robustness Tests on GDP variable estimations 
These take forever to estimate, but make sure to create a new table with the beta and standard error
for each model */


clear
cd "D:\Dropbox\Research Papers\Military Deployments and Coups\Data" 
use primary_coup_replication.dta
tsset ccode1 year
set seed 443439

/*model 2 */	
		
			
			tempname file_handle
			tempfile thousand_regressions
			postfile `file_handle' int dataset double intercept double lntroops100slope double lntroops100SE double mean_logslope double mean_logSE  using `thousand_regressions'
			tsset ccode year
			local i =1
			while `i' <=1000 {
			    generate double new_mean_log = rnormal(mean_log, sd_log)
				quietly logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.new_mean_log l.coldwar l.marxist i.ccode1,  robust
				post `file_handle' (`i') (_b[_cons]) (_b[l.lntroops100]) (_se[l.lntroops100]) (_b[l.new_mean_log]) (_se[l.new_mean_log])
				drop new_mean_log
				di `i'
				local i = `i'+1     
				}
	
	/*finish post estimation, then you can run the rest of the file */
				
							postclose `file_handle'
			use `thousand_regressions', clear
			
			
			
			tempname file_handler
			tempfile results
			postfile `file_handler' double troops double troopse double gdp double gdpse using `results'
			
			sum lntroops100slope
			tempvar troops
			tempvar troopse
			tempvar troopvar
			local troops = r(mean)
			local troopvar = r(Var)
			gen troopssesq = lntroops100SE^2 
			sum troopssesq
			
			local troopse = sqrt(r(mean) + ((1.001)*`troopvar'))
			
			sum mean_logslope
			tempvar gdp
			tempvar gdpse
			tempvar gdpvar
			local gdp = r(mean)
			local gdpvar = r(Var)
			gen mean_logSEsq = mean_logSE^2
			sum mean_logSEsq
			
			local gdpse = sqrt(r(mean) + (1.001)*`gdpvar')
			
			
			post `file_handler' (`troops') (`troopse') (`gdp') (`gdpse')
			postclose `file_handler'
			use `results', clear
			save latent_model_results_2.dta, replace
			
/* Model 3 */			
		
	use primary_coup_replication.dta, clear			
			tempname file_handle
			tempfile thousand_regressions
			postfile `file_handle' int dataset double intercept double lntroops100slope double lntroops100SE double mean_logslope double mean_logSE  using `thousand_regressions'
			tsset ccode year
			local i =1
			while `i' <=1000 {
			    generate double new_mean_log = rnormal(mean_log, sd_log)
				quietly logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.new_mean_log l.coldwar l.marxist l.past_coup i.ccode1,  robust
				post `file_handle' (`i') (_b[_cons]) (_b[l.lntroops100]) (_se[l.lntroops100]) (_b[l.new_mean_log]) (_se[l.new_mean_log])
				drop new_mean_log
				di `i'
				local i = `i'+1     
				}
				
							postclose `file_handle'
			use `thousand_regressions', clear
			
			
			
			tempname file_handler
			tempfile results
			postfile `file_handler' double troops double troopse double gdp double gdpse using `results'
			
			sum lntroops100slope
			tempvar troops
			tempvar troopse
			tempvar troopvar
			local troops = r(mean)
			local troopvar = r(Var)
			gen troopssesq = lntroops100SE^2 
			sum troopssesq
			
			local troopse = sqrt(r(mean) + ((1.001)*`troopvar'))
			
			sum mean_logslope
			tempvar gdp
			tempvar gdpse
			tempvar gdpvar
			local gdp = r(mean)
			local gdpvar = r(Var)
			gen mean_logSEsq = mean_logSE^2
			sum mean_logSEsq
			
			local gdpse = sqrt(r(mean) + (1.001)*`gdpvar')
			
			
			post `file_handler' (`troops') (`troopse') (`gdp') (`gdpse')
			postclose `file_handler'
			use `results', clear
			save latent_model_results_3.dta, replace
	
			
	/* model 4 */		
		
use primary_coup_replication.dta, clear			
		
			tempname file_handle
			tempfile thousand_regressions
			postfile `file_handle' int dataset double intercept double lntroops100slope double lntroops100SE double mean_logslope double mean_logSE  using `thousand_regressions'
			tsset ccode year
			local i =1
			while `i' <=1000 {
			    generate double new_mean_log = rnormal(mean_log, sd_log)
				quietly logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.new_mean_log l.coldwar l.marxist l.domestic4 l.excluded i.ccode1,  robust
				post `file_handle' (`i') (_b[_cons]) (_b[l.lntroops100]) (_se[l.lntroops100]) (_b[l.new_mean_log]) (_se[l.new_mean_log])
				drop new_mean_log
				di `i'
				local i = `i'+1     
				}
	
				
			postclose `file_handle'
			use `thousand_regressions', clear
			
			
			
			tempname file_handler
			tempfile results
			postfile `file_handler' double troops double troopse double gdp double gdpse using `results'
			
			sum lntroops100slope
			tempvar troops
			tempvar troopse
			tempvar troopvar
			local troops = r(mean)
			local troopvar = r(Var)
			gen troopssesq = lntroops100SE^2 
			sum troopssesq
			
			local troopse = sqrt(r(mean) + ((1.001)*`troopvar'))
			
			sum mean_logslope
			tempvar gdp
			tempvar gdpse
			tempvar gdpvar
			local gdp = r(mean)
			local gdpvar = r(Var)
			gen mean_logSEsq = mean_logSE^2
			sum mean_logSEsq
			
			local gdpse = sqrt(r(mean) + (1.001)*`gdpvar')
			
			
			post `file_handler' (`troops') (`troopse') (`gdp') (`gdpse')
			postclose `file_handler'
			use `results', clear
			save latent_model_results_4.dta, replace


/* model 5 */		
		
use primary_coup_replication.dta, clear				
			tempname file_handle
			tempfile thousand_regressions
			postfile `file_handle' int dataset double intercept double lntroops100slope double lntroops100SE double mean_logslope double mean_logSE  using `thousand_regressions'
			tsset ccode year
			local i =1
			while `i' <=1000 {
			    generate double new_mean_log = rnormal(mean_log, sd_log)
				quietly logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.new_mean_log l.coldwar l.marxist l.domestic4 l.excluded l.threat_env i.ccode1,  robust
				
				
				
				post `file_handle' (`i') (_b[_cons]) (_b[l.lntroops100]) (_se[l.lntroops100]) (_b[l.new_mean_log]) (_se[l.new_mean_log])
				drop new_mean_log
				di `i'
				local i = `i'+1     
				}
	
				
							postclose `file_handle'
			use `thousand_regressions', clear
			
			
			
			tempname file_handler
			tempfile results
			postfile `file_handler' double troops double troopse double gdp double gdpse using `results'
			
			sum lntroops100slope
			tempvar troops
			tempvar troopse
			tempvar troopvar
			local troops = r(mean)
			local troopvar = r(Var)
			gen troopssesq = lntroops100SE^2 
			sum troopssesq
			
			local troopse = sqrt(r(mean) + ((1.001)*`troopvar'))
			
			sum mean_logslope
			tempvar gdp
			tempvar gdpse
			tempvar gdpvar
			local gdp = r(mean)
			local gdpvar = r(Var)
			gen mean_logSEsq = mean_logSE^2
			sum mean_logSEsq
			
			local gdpse = sqrt(r(mean) + (1.001)*`gdpvar')
			
			
			post `file_handler' (`troops') (`troopse') (`gdp') (`gdpse')
			
			postclose `file_handler'
			use `results', clear
			
			save latent_model_results_5.dta, replace
			
/* model 6 */		
		
use primary_coup_replication.dta, clear				
			tempname file_handle
			tempfile thousand_regressions
			postfile `file_handle' int dataset double intercept double lntroops100slope double lntroops100SE double mean_logslope double mean_logSE  using `thousand_regressions'
			tsset ccode year
			local i =1
			while `i' <=1000 {
			    generate double new_mean_log = rnormal(mean_log, sd_log)
				quietly logit coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.new_mean_log l.coldwar l.marxist l.past_coup l.excluded l.time l.time2 l.time3 i.ccode1,  robust
				post `file_handle' (`i') (_b[_cons]) (_b[l.lntroops100]) (_se[l.lntroops100]) (_b[l.new_mean_log]) (_se[l.new_mean_log])
				drop new_mean_log
				di `i'
				local i = `i'+1     
				}
	
				
							postclose `file_handle'
			use `thousand_regressions', clear
			
			
			
			tempname file_handler
			tempfile results
			postfile `file_handler' double troops double troopse double gdp double gdpse using `results'
			
			sum lntroops100slope
			tempvar troops
			tempvar troopse
			tempvar troopvar
			local troops = r(mean)
			local troopvar = r(Var)
			gen troopssesq = lntroops100SE^2 
			sum troopssesq
			
			local troopse = sqrt(r(mean) + ((1.001)*`troopvar'))
			
			sum mean_logslope
			tempvar gdp
			tempvar gdpse
			tempvar gdpvar
			local gdp = r(mean)
			local gdpvar = r(Var)
			gen mean_logSEsq = mean_logSE^2
			sum mean_logSEsq
			
			local gdpse = sqrt(r(mean) + (1.001)*`gdpvar')
			
			
			post `file_handler' (`troops') (`troopse') (`gdp') (`gdpse')
			
			postclose `file_handler'
			use `results', clear
			
			save latent_model_results_6.dta, replace
clear
use primary_coup_replication.dta

/*base models */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.troops, robust
eststo: logit coup l.troops l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist,  robust
eststo: logit coup l.troops l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup,  robust
eststo: logit coup l.troops l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.domestic4 l.excluded,  robust
eststo: logit coup l.troops l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded l.time l.time2 l.time3,  robust


esttab _all using ..\Tables\Basic_Results_no_fe_Predictive.tex, replace ///
	mtitles("Naive" "Controls" "Past Coups" "Excluded" "Cubic Polynomial")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; standard errors in parentheses." ///
	"$*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")


/* Spatial controls */
set more off
eststo clear
tsset ccode1 year
eststo: logit coup l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_coup,  robust
eststo: logit coup l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_demo,  robust
eststo: logit coup l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded l.sp_lntroops100,  robust



esttab _all using ..\Tables\Spatial_Results_no_fe_Predictive.tex, replace ///
	mtitles("Spatial Coups" "Spatial Democracies"  "Spatial Troops")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) ///
	compress nonotes eqlabels(none)  ///
	addnote("Two-tailed tests reported for all variables; standard errors in parentheses." ///
	"$*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")

/* Coup types */
set more off
eststo clear
tsset ccode1 year
eststo: logit attempt l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded,  robust
eststo: logit military l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log  l.coldwar l.marxist l.past_coup l.excluded,  robust
eststo: logit coup l.troops l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded if l.demo_dummy == 1,  robust
eststo: logit coup l.troops l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.past_coup l.excluded if  l.demo_dummy == 0,  robust
eststo: logit coup l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.marxist l.past_coup l.excluded if  coldwar == 1,  robust
eststo: logit coup l.troops l.demo_dummy l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.past_coup l.excluded if marxist == 0 ,  robust
 

esttab _all using ..\Tables\Sub_Samples_Results_no_fe_Predictive.tex, replace ///
	mtitles("Attempts" "Military" "Democracies" "Non-Democracies" "Cold War" "Non-Marxist")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) ///
	compress nonotes eqlabels(none) ///
	addnote("Two-tailed tests reported for all variables; standard errors in parentheses." ///
	"$*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "")
		

//3sls
set more off
eststo clear
tsset ccode1 year
eststo: reg3 (coup l.lntroops100 l.demo_dummy  l.lnpop_cnts l.delta01 l.mean_log l.coldwar l.marxist l.domestic4 l.excluded i.ccode1) (l.lntroops100 l2.threat_env l2.lntroops100 l2.demo_dummy  l2.lnpop_cnts l2.delta01 l2.mean_log l2.coldwar l2.marxist l2.domestic4 l2.excluded)


esttab _all using ..\Tables\3sls_endogeneity.tex, replace ///
	mtitles("3SLS")   ///
	scalars("r2_p Pseudo $ R^2$" N) style(tex)   b(%9.3gc) obslast label se nogaps  ///
	star(* 0.10 ** 0.05 *** 0.01)  alignment(S) unstack ///
	compress nonotes eqlabels(none) drop(*.ccode1) ///
	addnote("Two-tailed tests reported for all variables; standard errors in parentheses." ///
	"Fixed effects results not reported. $*$ p$\leq$ 0.10; $**$ p$\leq$ 0.05; $***$ p$\leq$0.01.") ///
		substitute(L_ "" L. "" L2. "")
	
			